package org.melanesia.sql.exceptions;

import org.melanesia.sql.BatchResult;

/**
 * Exception thrown from the {@link org.melanesia.sql.Batch#execute()} method,
 * when error occurs in one (or more) of the batched queries.
 *
 * @author marcin.kielar
 *
 */
public class BatchExecutionException extends SQLExecutionException {

    /** Serial version uid for serialization. */
    private static final long serialVersionUID = -8953652219750805017L;

    /** Structure holding results of batch query execution. */
    private final BatchResult batchResult;

    /**
     * Creates new {@code BatchExecutionException}.
     *
     * @param message
     *            message
     * @param batchResult
     *            result of the batch query execution
     */
    public BatchExecutionException(final String message, final BatchResult batchResult) {
        super(message);
        this.batchResult = batchResult;
    }

    /**
     * Returns a structure holding results of the failed batch execution.
     *
     * @return results of the batch query execution.
     */
    public final BatchResult getBatchResult() {
        return batchResult;
    }

}
